<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_Projetregional extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Idprojetregional;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Idgoverneras;

    /**
     * Database var type text
     *
     * @var text
     */
    protected $_Nomdeprojet;

    /**
     * Database var type text
     *
     * @var text
     */
    protected $_Description;


    /**
     * Parent relation fk_projetregional_governeras1
     *
     * @var Application_Model_Governeras
     */
    protected $_Governeras;


    /**
     * Dependent relation fk_fichierdeprojet_projetregional1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_Fichierdeprojet
     */
    protected $_Fichierdeprojet;

    /**
     * Dependent relation fk_listeprojetsregional_projetregional1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_Listeprojetsregional
     */
    protected $_Listeprojetsregional;

    /**
     * Dependent relation fk_usersprojets_projetregional1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_Usersprojets
     */
    protected $_Usersprojets;

    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'idprojetregional'=>'Idprojetregional',
            'idgoverneras'=>'Idgoverneras',
            'nomdeprojet'=>'Nomdeprojet',
            'description'=>'Description',
        ));

        $this->setParentList(array(
            'FkProjetregionalGoverneras1'=> array(
                    'property' => 'Governeras',
                    'table_name' => 'Governeras',
                ),
        ));

        $this->setDependentList(array(
            'FkFichierdeprojetProjetregional1' => array(
                    'property' => 'Fichierdeprojet',
                    'table_name' => 'Fichierdeprojet',
                ),
            'FkListeprojetsregionalProjetregional1' => array(
                    'property' => 'Listeprojetsregional',
                    'table_name' => 'Listeprojetsregional',
                ),
            'FkUsersprojetsProjetregional1' => array(
                    'property' => 'Usersprojets',
                    'table_name' => 'Usersprojets',
                ),
        ));
    }

    /**
     * Sets column idprojetregional
     *
     * @param int $data
     * @return Application_Model_Projetregional
     */
    public function setIdprojetregional($data)
    {
        $this->_Idprojetregional = $data;
        return $this;
    }

    /**
     * Gets column idprojetregional
     *
     * @return int
     */
    public function getIdprojetregional()
    {
        return $this->_Idprojetregional;
    }

    /**
     * Sets column idgoverneras
     *
     * @param int $data
     * @return Application_Model_Projetregional
     */
    public function setIdgoverneras($data)
    {
        $this->_Idgoverneras = $data;
        return $this;
    }

    /**
     * Gets column idgoverneras
     *
     * @return int
     */
    public function getIdgoverneras()
    {
        return $this->_Idgoverneras;
    }

    /**
     * Sets column nomdeprojet
     *
     * @param text $data
     * @return Application_Model_Projetregional
     */
    public function setNomdeprojet($data)
    {
        $this->_Nomdeprojet = $data;
        return $this;
    }

    /**
     * Gets column nomdeprojet
     *
     * @return text
     */
    public function getNomdeprojet()
    {
        return $this->_Nomdeprojet;
    }

    /**
     * Sets column description
     *
     * @param text $data
     * @return Application_Model_Projetregional
     */
    public function setDescription($data)
    {
        $this->_Description = $data;
        return $this;
    }

    /**
     * Gets column description
     *
     * @return text
     */
    public function getDescription()
    {
        return $this->_Description;
    }

    /**
     * Sets parent relation Idgoverneras
     *
     * @param Application_Model_Governeras $data
     * @return Application_Model_Projetregional
     */
    public function setGoverneras(Application_Model_Governeras $data)
    {
        $this->_Governeras = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idgoverneras'];
        }

        $this->setIdgoverneras($primary_key);

        return $this;
    }

    /**
     * Gets parent Idgoverneras
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Governeras
     */
    public function getGoverneras($load = true)
    {
        if ($this->_Governeras === null && $load) {
            $this->getMapper()->loadRelated('FkProjetregionalGoverneras1', $this);
        }

        return $this->_Governeras;
    }

    /**
     * Sets dependent relations fk_fichierdeprojet_projetregional1
     *
     * @param array $data An array of Application_Model_Fichierdeprojet
     * @return Application_Model_Projetregional
     */
    public function setFichierdeprojet(array $data)
    {
        $this->_Fichierdeprojet = array();

        foreach ($data as $object) {
            $this->addFichierdeprojet($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_fichierdeprojet_projetregional1
     *
     * @param Application_Model_Fichierdeprojet $data
     * @return Application_Model_Projetregional
     */
    public function addFichierdeprojet(Application_Model_Fichierdeprojet $data)
    {
        $this->_Fichierdeprojet[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_fichierdeprojet_projetregional1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_Fichierdeprojet
     */
    public function getFichierdeprojet($load = true)
    {
        if ($this->_Fichierdeprojet === null && $load) {
            $this->getMapper()->loadRelated('FkFichierdeprojetProjetregional1', $this);
        }

        return $this->_Fichierdeprojet;
    }

    /**
     * Sets dependent relations fk_listeprojetsregional_projetregional1
     *
     * @param array $data An array of Application_Model_Listeprojetsregional
     * @return Application_Model_Projetregional
     */
    public function setListeprojetsregional(array $data)
    {
        $this->_Listeprojetsregional = array();

        foreach ($data as $object) {
            $this->addListeprojetsregional($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_listeprojetsregional_projetregional1
     *
     * @param Application_Model_Listeprojetsregional $data
     * @return Application_Model_Projetregional
     */
    public function addListeprojetsregional(Application_Model_Listeprojetsregional $data)
    {
        $this->_Listeprojetsregional[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_listeprojetsregional_projetregional1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_Listeprojetsregional
     */
    public function getListeprojetsregional($load = true)
    {
        if ($this->_Listeprojetsregional === null && $load) {
            $this->getMapper()->loadRelated('FkListeprojetsregionalProjetregional1', $this);
        }

        return $this->_Listeprojetsregional;
    }

    /**
     * Sets dependent relations fk_usersprojets_projetregional1
     *
     * @param array $data An array of Application_Model_Usersprojets
     * @return Application_Model_Projetregional
     */
    public function setUsersprojets(array $data)
    {
        $this->_Usersprojets = array();

        foreach ($data as $object) {
            $this->addUsersprojets($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_usersprojets_projetregional1
     *
     * @param Application_Model_Usersprojets $data
     * @return Application_Model_Projetregional
     */
    public function addUsersprojets(Application_Model_Usersprojets $data)
    {
        $this->_Usersprojets[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_usersprojets_projetregional1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_Usersprojets
     */
    public function getUsersprojets($load = true)
    {
        if ($this->_Usersprojets === null && $load) {
            $this->getMapper()->loadRelated('FkUsersprojetsProjetregional1', $this);
        }

        return $this->_Usersprojets;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Projetregional
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Projetregional());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Projetregional::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIdprojetregional() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('idprojetregional = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIdprojetregional()));
    }
}
